package www;

import java.util.ArrayList;
import java.util.List;

/**
 * Creared with IntelliJ IDEA.
 * Description:杨辉三角
 * User:yxd
 * Date:2022-01-04
 * Time:16:04
 */
public class Two {
    public static void main(String[] args) {
        ArrayList<List<Integer>> array = new ArrayList<>();//要放入杨辉三角的类
        List<Integer> list1 = new ArrayList<>();//第一行
        list1.add(1);
        array.add(list1);//把第一行存放到array中
        for(int i = 1;i < 25;i ++){//每行
            List<Integer> list2 = new ArrayList<>();
            list2.add(1);//每个开头都是1
            List<Integer> pre = array.get(i - 1);//上一行的数据
            for (int j = 1; j < i; j++) {
                list2.add(pre.get(j) + pre.get(j - 1));//这个数是上一行的此位置和前一个位置的和
            }

            list2.add(1);//每个结尾都是1
            array.add(list2);//再把此行放入array
        }
        //System.out.println(array);
        System.out.println(modifyString("??yw?ipkj?"));
    }
    public static String modifyString(String s) {
        StringBuilder s1 = new StringBuilder();
        char[] a = s.toCharArray();
        if(a[0] == 63 && a[1] != 63 &&  a[1] != 97 ){
            a[0] = (char)(a[1] - 1);
        }else if(a[1] == 63) {
            a[0] = (char) 97;
        }else if(a[1] == 97){
            a[0] = (char)(a[1] + 1);
        }
        s1.append(a[0]);
        for(int i = 1;i < a.length - 1;i ++){
            char ch = a[i];
            char prev = a[i - 1];
            char next = a[i + 1];
            if(ch != 63){
                s1.append(ch);
            }else{
                if(prev != 97 && next != 97) {
                    ch = (char) 97;

                }else if(prev != 98 && next != 98){
                    ch = (char) 98;
                }else{
                    ch = (char)99;
                }
                s1.append(ch);
            }
        }
        if(a[a.length - 1 ] == 63 && a[a.length - 2] != 122){
            a[a.length - 1] =(char)(a[a.length - 2] + 1);
        }else if(a[a.length - 2] == 122){
            a[a.length - 1] = (char) 97;
        }
        s1.append(a[a.length - 1]);
        String h = s1.toString();
        return h;
    }
}
